*&---------------------------------------------------------------------*
*& Report YBC_SWS_TEST01
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT YBC_SWS_TEST01.

PARAMETERS:
  P_REQID TYPE YBC_SWS_REQJSON-REQUESTID OBLIGATORY.

PARAMETERS:
  P_DEL TYPE C AS CHECKBOX.

DATA:
  GV_HEADJSON  TYPE STRING,
  GV_ITEMHJSON TYPE STRING,
  GV_ITEMRJSON TYPE STRING.

INITIALIZATION.


AT SELECTION-SCREEN.

  GV_HEADJSON = '[{"FIELD":"PLANID","NAME1":"工作计划编号","NAME2":"","NAME3":"","VALUE":"100000000029","PLATFORM":""},' &&
                  '{"FIELD":"SWERK&NAME1","NAME1":"维护工厂","NAME2":"","NAME3":"","VALUE":"3492 XXXX工厂","PLATFORM":""},' &&
                  '{"FIELD":"PLANTYPTX","NAME1":"计划类型描述","NAME2":"","NAME3":"","VALUE":"定期给油脂","PLATFORM":""},' &&
                  '{"FIELD":"SPECL&NAME2","NAME1":"专业","NAME2":"","NAME3":"","VALUE":"06 XXXX专业","PLATFORM":""},' &&
                  '{"FIELD":"PLANBG","NAME1":"开始日期","NAME2":"","NAME3":"","VALUE":"20200610","PLATFORM":""}]'.

  GV_ITEMHJSON = '[{"Name1": "行项目","Name2": "Item","Name3": ""},{"Name1": "物料","Name2": "Material","Name3": ""}]'.
  GV_ITEMRJSON = '[{"EBELP": "001","MATNR": "MAT006"}, {"EBELP": "002","MATNR": "MET008"}, {"EBELP": "003","MATNR": "YT006"}]'.


START-OF-SELECTION.

  IF P_DEL IS NOT INITIAL.
    DELETE  FROM YBC_SWS_REQUEST.
    DELETE FROM YBC_SWS_REQJSON.
    DELETE FROM YBC_SWS_APPROVER.
    DELETE FROM YBC_SWS_USER.

    COMMIT WORK AND WAIT.

    MESSAGE '数据表已全部清空！'  TYPE 'I'.

  ELSE.

    DATA:
      LS_REQJSON TYPE YBC_SWS_REQJSON.

    LS_REQJSON-REQUESTID = P_REQID.
    LS_REQJSON-HEADJSON = GV_HEADJSON.
    LS_REQJSON-ITEMHJSON = GV_ITEMHJSON.
    LS_REQJSON-ITEMRJSON = GV_ITEMRJSON.

    MODIFY YBC_SWS_REQJSON FROM LS_REQJSON.

    IF SY-SUBRC = 0.
      MESSAGE 'Success!' TYPE 'I'.
    ENDIF.
  ENDIF.

END-OF-SELECTION.
